setTimeout(function(){
  var a = 'hello'
  setTimeout(function(){
      var b = 'lagou'
      setTimeout(function(){
        var c = 'I love U'
        console.log(a+b+c)
      },10)
	},10)
},10)


const fp = require('lodash/fp')
//数据
//horsepower 马力， dollar_value 价格，in_stock 库存
const cars = [
    {name: 'Ferrari FF1', horsepower: 660, dollar_value: 700000, in_stock: true},
    {name: 'Ferrari FF2', horsepower: 650, dollar_value: 648000, in_stock: false},
    {name: 'Ferrari FF3', horsepower: 550, dollar_value: 132000, in_stock: false},
    {name: 'Ferrari FF4', horsepower: 525, dollar_value: 114200, in_stock: false},
    {name: 'Ferrari FF5', horsepower: 750, dollar_value: 1850000, in_stock: true},
    {name: 'Ferrari FF6', horsepower: 700, dollar_value: 1300000, in_stock: false},

]

let isLastInStock = function (cars){
    //获取最后一条数据
    let last_car = fp.last(cars)
    //获取最后一条数据的in_stock属性值
    return fp.prop('in_stock', last_car)
}

let _average = function (xs){
    return fp.reduce(fp.add, 0, xs) / xs.length
}
let averageDollarValue = function (cars)
{
    let dollar_values = fp.map(function (car){
        return car.dollar_value
    }, cars)
    return _average(dollar_values)
}


let _underscore = fp.replace(/\W+/g, '_')

//support.js
class Container{
    static of(value){
        return new Container(value)
    }
    constructor(value){
        this._value = value
    }
    map(fn){
        return Container.of(fn(this.value))
    }
}
class Maybe{
    static of(x){
        return new Maybe(x)
    }
    isNothing(){
        return this.value === null ||
        this._value === undefined
    }
    constructor(x){
        this._value = x
    }
    map(fn){
        return this.isNothing() ? this : Maybe.of(fn(this._value))
    }
}

module.exports = {Maybe, Container}

//app.js
const fp = require('lodash/fp')
const {Maybe, Container} =
require('./support')
let maybe = Maybe.of([5,6,1])
let ex1 = () =>{
    //需要实现的函数。。。
}

//app.js
const fp = require('lodash/fp')
const {Maybe, Container} =
require('./support')
let xs = Container.of([
    'do','ray','me','fa','so','la','ti','do'
])
let ex2 = () =>{
    //需要实现的函数。。。
}

//app.js
const fp = require('lodash/fp')
const {Maybe, Container} =
require('./support')
let safeProp = fp.curry(function(x,o){
    return Maybe.of(o[x])
})
let user = {id:2, name:'Albert'}
let ex3 = () =>{
     //需要实现的函数。。。
}

//app.js
const fp = require('lodash/fp')
const {Maybe, Container} =
require('./support')
let ex4 = function (n) {
    if(n){
        return parseInt(n)
    }
}